package validation

import (
	"go_batch_create_orders/admin/model"
	"go_batch_create_orders/utils"
)

type SpecValidation struct {
}

func (SpecValidation) ValidateItemAdd(model model.SpecItem) (err error) {
	err = utils.ValidateData(&model,
		utils.ValidateFields(&model.ItemName, utils.Required("规格名称必填")),
		utils.ValidateFields(&model.CategoryId, utils.Required("规格分类必填")),
	)
	return
}

func (SpecValidation) ValidateItemUpdate(model model.SpecItem) (err error) {
	err = utils.ValidateData(&model,
		utils.ValidateFields(&model.ItemName, utils.Required("规格名称必填")),
		utils.ValidateFields(&model.CategoryId, utils.Required("规格分类必填")),
		utils.ValidateFields(&model.Id, utils.Required("id必填")),
	)
	return
}

func (SpecValidation) ValidateModelAdd(model model.SpecModel) (err error) {
	err = utils.ValidateData(&model,
		utils.ValidateFields(&model.ModelName, utils.Required("模型必填")),
	)
	return
}

func (SpecValidation) ValidateModelUpdate(model model.SpecModel) (err error) {
	err = utils.ValidateData(&model,
		utils.ValidateFields(&model.ModelName, utils.Required("模型必填")),
		utils.ValidateFields(&model.Id, utils.Required("id必填")),
	)
	return
}

func (SpecValidation) ValidateModelDel(model model.SpecModel) (err error) {
	err = utils.ValidateData(&model,
		utils.ValidateFields(&model.Id, utils.Required("id必填")),
	)
	return
}

func (SpecValidation) ValidateCateGoryAdd(model model.SpecCateGory) (err error) {
	err = utils.ValidateData(&model,
		utils.ValidateFields(&model.CategoryName, utils.Required("属性分类名称必填")),
		utils.ValidateFields(&model.ModelId, utils.Required("属性分类模型必填")),
	)
	return
}

func (SpecValidation) ValidateCateGoryUpdate(model model.SpecCateGory) (err error) {
	err = utils.ValidateData(&model,
		utils.ValidateFields(&model.Id, utils.Required("分类Id必填")),
		utils.ValidateFields(&model.CategoryName, utils.Required("属性分类名称必填")),
		utils.ValidateFields(&model.ModelId, utils.Required("属性分类模型必填")),
	)
	return
}
